package com.yunsuo.bean;

import com.alibaba.fastjson.JSON;

public class DoorStatusThread extends Thread{

    final HttpConnectionFinal httpConnection = new HttpConnectionFinal();

    @Override
    public void run() {
        while(true){
            ////System.out.println("获得门的状态");
            DoorStatus doorStatus=new DoorStatus();
            doorStatus.getConn();
            LockRaspberry lockRaspberry =doorStatus.getAll();
            if(lockRaspberry.getlModify()==1){
                String jsonString = JSON.toJSONString(lockRaspberry);
                //System.out.println("sssssssssssssss");
                //System.out.println(jsonString);
                final String info = "info="+jsonString;
                String result = httpConnection.connection("/raspberry/doorStatus",info);
                //System.out.println("result="+result);
                doorStatus.update(lockRaspberry.getlId());
            }else{
                //System.out.println("门锁状态未改变");
            }

            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }





}
